home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17730 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  83 lines

  1. Path: gidora.kralizec.net.au!root
  2. From: srsawyer@zeta.org.au (Stephen Sawyer)
  3. Newsgroups: comp.lang.c++
  4. Subject: Problems passing Device Context handels from VB 4.0 to VC++2.0 DLLÆs
  5. Date: Wed, 17 Apr 1996 07:49:27 GMT
  6. Organization: Kralizec Dialup Internet Sydney, +61-2-837-1183 V.32bis
  7. Message-ID: <4l2bbd$mto@gidora.kralizec.net.au>
  8. NNTP-Posting-Host: dialup05.syd1.zeta.org.au
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. If anyone has has any experiance in writing VC++ DLLs and passing
  12. Device Context handels from VB 4.0, I would realy appresiate your
  13. help.   I am trying to sent a Device Context handel  from VB 4.0 to a
  14. VC++ 2.0 custom DLL but as you can see from my debugger watch values,
  15. I do not receive a proper Device Context (hDC) in my VC++ DLL and the
  16. result is my DLL crashes.  However I can call the same DLL from a test
  17. program in VC++ and it works correctly.
  18.  
  19. My VB calling procedure declaration is of the form 
  20.  
  21.     Declare Function MyPassHDC Lib "MyDll.dll" (ByVal hdc As Long) As
  22. Integer
  23.  
  24. and my C++ receiving declaration is
  25.     
  26.     int pascal MyPassHDC(CDC* hDC)
  27.  
  28. If I pass a picture control to the DLL in the following way
  29.  
  30.     MsgBox (MyPicture.hdc)      æDiagnostic check to note the value of
  31. hdc
  32.     Result = MyPassHDC(MyPicture.hdc)     æCall the function in MyDll.dll
  33.  
  34. I get for example a value of  5190  for MyPicture.hdc in the Message
  35. Box and the following in the VC++ debugger for the same hDC value in
  36. the DLL
  37.  
  38. VC++ debugger result ............
  39. -hDC = 0x00001446      //( = 5190dec)
  40.   -CObject = {...}
  41.     -__vfptr = 0x00000000   //(invalid??)
  42.        [0] = 0x00c90f9e
  43.        [1] = 0x00700465
  44.        [2] = 0x04950016
  45.        [3] = 0x00700465
  46.        [4] = 0x00700465
  47.   -m_hDC = 0x00000000   //(invalid??)
  48.      unused = 13176734
  49.   -m_hAttribDC = 0x00000000   //(invalid??)
  50.      unused = 13176734
  51.    m_bPrinting = 0   //(invalid??)
  52.  
  53. Why Do I get values of  0x00000000 for -__vfptr, m_hDC, m_hAttribDC
  54. ????
  55.  
  56.  
  57. As you can see below I get proper working values for the hdc of if I
  58. call the DLL from C++ program
  59.  
  60. VC++ debugger result ............
  61. -hDC = 0x00651278
  62.   -CObject = {...}
  63.     -__vfptr = 0x5f8867a8
  64.        [0] = 0x5f871577 CDC::GetRuntimeClass(void)
  65.        [1] = 0x5f87db80 <no type> CDC::`vector deleting destructor'
  66.        [2] = 0x5f85a5f1 CObject::Serialize(&)
  67.        [3] = 0x5f825d0d CDC::AssertValid(void)
  68.        [4] = 0x5f825d2b CDC::Dump(& &)
  69.   -m_hDC = 0x000005f6
  70.      unused = -277897221
  71.   -m_hAttribDC = 0x000005f6
  72.      unused = -277897221
  73.    m_bPrinting = 0
  74.  
  75. I would very much appreciate and help, information or tips on this
  76. Thanks in advance
  77.  
  78. Stephen Sawyer
  79. srsawyer@zeta.org.au
  80.  
  81.  
  82.  
  83.